﻿using Framework.Utility.Helper;
using Microsoft.Extensions.Logging;
using MonitorCode.Hangfire;
using System.Data;

namespace MonitorCode.NPS
{
    public class NPSService : INPSService
    {
        private ILogger<NPSService> _logger;

        public NPSService(ILogger<NPSService> logger)
        {
            _logger = logger;
        }

        public NPSService()
        {
        }

        public int GetSqlTest(string connstr, string sql)
        {
            var conn = new SqlHelper(connstr);

            var ret = conn.GetScalarInt(sql);

            return ret;
        }

        public int GetMysqlTest(string connstr, string sql)
        {
            //sbr.Append("UPDATE test_table SET ");
            //sbr.Append("name='13', ");
            //sbr.Append("password='333' ");
            //sbr.Append("WHERE id=@id;");
            //cmdText = sbr.ToString();
            //MySqlParameter idParm = new MySqlParameter("@id", 2);

            DataTable dt = MySqlUtilsHelper.GetDataTable(connstr, CommandType.Text, sql);
            _logger.LogInformation("结果行数：" + dt.Rows.Count);
             
            var ret = dt.Rows.Count;

            return ret;
        }
    }
}